/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package billing;

import java.util.HashMap;
import java.util.Vector;

/**
 *
 * @author apple
 */
public class AreasModel extends My_Model{
    
    String id;
    String name;
    
    public AreasModel() throws Exception{
        tableName = "areas";
    }
    
    public boolean checkAreaNameExist(String areaName) throws Exception{
        String sql = String.format("SELECT * from %s WHERE name = '%s'", tableName,areaName);
        Vector result = to_models(getData(sql));
        return (result.size() > 0) ? true : false;
    }

    @Override
    public My_Model to_model(HashMap<String, String> data) throws Exception {
        AreasModel model = new AreasModel();
        model.id = (data.get("id") != null ) ? data.get("id") : "";
        model.name = (data.get("name") != null ) ? data.get("name") : "";
        
        return model;
    }
    
    
    
}
